#ifndef CHOOSEFRIENDDIALOG_H
#define CHOOSEFRIENDDIALOG_H

#include <QWidget>
#include <QDialog>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QScrollArea>
#include <QScrollBar>
#include "debug.h"
#include <QCheckBox>
#include <QPushButton>
#include <QLabel>
#include "model/datacenter.h"
#include "toast.h"

class ChooseFriendDialog : public QDialog
{
    Q_OBJECT
public:
    ChooseFriendDialog(QWidget *parent,const QString& userId);

    void addFriend(const QString& userId, const QIcon& avatar, const QString&name, bool checked);
    void addSelectedFriend(const QString& userId, const QIcon& avatar, const QString& name);
    void deleteSelectedFriend(const QString& userId);

    QString getUserId(){return userId;}
private:
    QWidget* totalContainer;
    QWidget* selectedContainer;

    void initLeft(QHBoxLayout* layout);
    void initRight(QHBoxLayout* layout);

    const QString& userId;


    //加载数据
    void initData();
    //点击 确定按钮的逻辑
    void clickYesBtn();
    //获取右侧好友列表中的用户
    QList<QString> generateMemberList();



signals:
};

class ChooseFriendItem : public QWidget
{
    Q_OBJECT
public:
    ChooseFriendItem(ChooseFriendDialog* owner, const QString& userId, const QIcon& avatar, const QString& name, bool checked);

    ChooseFriendDialog* owner;
    const QString userId;
    const QIcon avatar;
    const QString name;
    QCheckBox* checkBox;
    bool isHover; //是否有光标在该控件上

signals:
private:
    void toggleCheckBox(bool checked);
};



#endif // CHOOSEFRIENDDIALOG_H
